﻿namespace NuGetCop.MSBuild.Tasks.Configuration.Readers
{
    using System;
    using System.Diagnostics.Contracts;
    using System.Xml;

    internal sealed class NuGetCopSettingsXmlReaderFactory : INuGetCopSettingsReaderFactory
    {
        private readonly XmlReaderSettings xmlReaderSettings;

        public NuGetCopSettingsXmlReaderFactory(
            XmlReaderSettings xmlReaderSettings)
        {
            Contract.Requires(xmlReaderSettings != null);

            this.xmlReaderSettings = xmlReaderSettings;
        }

        public INuGetCopSettingsReader<Uri> CreateReader()
        {
            var xmlSettingsReader = new NuGetCopSettingsXmlReader();
            var streamSettingsReader = new NuGetCopSettingsXmlStreamReader(xmlReaderSettings, xmlSettingsReader);
            var webSettingsReader = new NuGetCopSettingsWebReader(streamSettingsReader);

            return webSettingsReader;
        }
    }
}
